package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.album.service.BaseAttributeService;
import com.atguigu.tingshu.album.service.BaseCategoryService;

import com.atguigu.tingshu.common.anno.GuiguLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.common.result.ResultCodeEnum;
import com.atguigu.tingshu.model.album.BaseAttribute;
import com.atguigu.tingshu.model.album.BaseCategory3;
import com.atguigu.tingshu.model.album.BaseCategoryView;
import com.atguigu.tingshu.vo.album.AlbumCategoryVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value="/api/album/category")
@SuppressWarnings({"unchecked", "rawtypes"})
public class BaseCategoryApiController {
	
	@Autowired
	private BaseCategoryService baseCategoryService;

	@Autowired
	private BaseAttributeService baseAttributeService ;


	//@GuiguLogin
     @Tag(name = "查询所有分类")
	 @GetMapping(value = "/getBaseCategoryList")
	 public Result<List<AlbumCategoryVo>> finAllCategory(){
		 List<AlbumCategoryVo> albumCategoryVoList = baseCategoryService.findAllCategory() ;
		 return Result.build(albumCategoryVoList , ResultCodeEnum.SUCCESS) ;
	 }

	 @Tag(name = "根据分类Id查询专辑属性")
	 @GetMapping(value = "/findAttribute/{category1Id}")
	 public Result<List<BaseAttribute>> findAttributeByC1Id(@PathVariable(value = "category1Id") Long category1Id) {
		 List<BaseAttribute> attributeList = baseAttributeService.findAttributeByC1Id(category1Id) ;
		 return Result.ok(attributeList) ;
	 }
	 @Operation(summary = "根据三级分类id查询一级二级分类-feign")
	 @GetMapping(value = "findByCategoryBy3Id/{category3id}")
	 public Result<BaseCategoryView> findByCategoryBy3Id(@PathVariable(value = "category3id") Long category3id){
		 BaseCategoryView baseCategoryView = baseCategoryService.findByCategoryBy3Id(category3id);
		 return Result.ok(baseCategoryView);
	  }


	  // com.atguigu.tingshu.album.api.BaseCategoryApiController
	  @Tag(name = "点击首页全部按钮")
	  @Operation(summary = "根据一级分类id获取全部分类信息")
	  @GetMapping(value = "/getBaseCategoryList/{category1Id}")

	 public Result<AlbumCategoryVo> getBaseCategoryList(@PathVariable(name = "category1Id") Long category1Id){
		 AlbumCategoryVo albumCategoryVo = baseCategoryService.getBaseCategoryList(category1Id);
		 return Result.ok(albumCategoryVo);
	  }

	  @Tag(name = "点击最上面一级列表下方显示其包含的三级分类")
	 @Operation(summary = "根据一级分类id查询置顶三级分类")
	 @GetMapping(value ="findTopBaseCategory3/{category1Id}" )
	 public Result<List<BaseCategory3>> findTopBaseCategory3(@PathVariable(name = "category1Id") Long categort1Id){
		 List<BaseCategory3> category3List = baseCategoryService.findTopBaseCategory3(categort1Id);
		 return Result.ok(category3List);
	  }




}

